package com.exam.zhaohang;

import java.util.Scanner;

/**
 * date:
 * description:
 */
public class Solution001 {
    public static void main(String[] args) {
        System.out.println(Integer.MAX_VALUE);
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] nums1 = new int[n];
        int[] nums2 = new int[m];
        int count4 = 0;
        int count2 = 0;
        for (int i = 0; i < n; i++) {
            int input = scanner.nextInt();
            if(input % 4 == 0){
                nums1[i] = 4;
            }else if(input % 2 == 0){
                nums1[i] = 2;
            }else{
                nums1[i] = 1;
            }
        }
        for (int i = 0; i < m; i++) {
            int input = scanner.nextInt();
            if(input % 4 == 0){
                nums2[i] = 4;
                count4++;
                count2++;
            }else if(input % 2 == 0){
                nums2[i] = 2;
                count2++;
            }else{
                nums2[i] = 1;
            }
        }
        int res = 0;
        for (int i = 0; i < n; i++) {
            if(nums1[i] == 4){
                res += m;
            }else if(nums1[i] ==2){
                res += count2;
            }else{
                res += count4;
            }
        }
        System.out.println(res);

    }
}
